import React, { Component } from 'react';
import {render} from 'react-dom';
import {
    HashRouter as Router,
    Route,
    Link,
    Redirect,
    Switch
} from './react-router-dom'
import Home from './home.js';
import Profile from './profile.js';
import User from './user.js';
export default class App extends Component{
    constructor(){
        super();
    }
    render(){
        return(<Router>
            <div>
                <div>
                    <Link to='/home'>首页</Link>
                    <Link to='/profile'>个人中心</Link>
                    <Link to='/user'>用户</Link>
                </div>
                <div>
                    {/*extract严格匹配 */}
                    <Switch>
                        <Route path='/home' component={Home}></Route>
                        <Route path='/profile' component={Profile}></Route>
                        <Route path='/user' component={User}></Route>
                        <Redirect to='/home'></Redirect>
                    </Switch>
                </div>
            </div>
        </Router>)
    }
}
render(<App></App>,document.getElementById('root'))
